/*
 * ChooseVillage.java
 *
 * Created on 13 maart 2008, 22:36
 */
package gui;

/**
 *
 * @author groep 11
 * @date 2007-2008
 */
import gui.panels.FriendsControl;
import gui.panels.UpperBar;
import gui.panels.VillageInfo;
import data.*;
import gui.panels.WorldMap;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import maiaclient.Maia;

public class ChooseVillage extends AbstrWorld {

    // Final Fields
    final String CHOOSEVILLAGETITLE = "Maia - Choose Village Location";
    final String IMAGEICONLOC = "src/img/logo.gif";
    final String NATUREXML = "src/data/nature.xml";
    //fields
    private Maia maia;

    public ChooseVillage(Maia maia) {

        // Sets the frame options (title, closing operation, IconImage)     
//+     //setUndecorated(true);
//        setResizable(false);
        setTitle(CHOOSEVILLAGETITLE);
        Image icon = Toolkit.getDefaultToolkit().getImage(IMAGEICONLOC);
        setIconImage(icon);

        // Passing Maia connection to new GUI
        setMaia(maia);

        // Init default and dynamic created controls
        initComponents();
        initChooseVillageComponents();

        //Sets the frame to fullscreen 
        GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
        GraphicsDevice device = env.getDefaultScreenDevice();
        try {
            GraphicsConfiguration gc = device.getDefaultConfiguration();
            device.setFullScreenWindow(this);
        } catch (Exception e) {
            e.printStackTrace();

        }
    }

    public void initChooseVillageComponents() {

        // Sets the Main Container  
        JPanel content = new JPanel();
        content.setLayout(new BorderLayout());
        setContentPane(content);

        //Panel at the right with ControlFriends and VillageInfo panels
        JPanel pnlRight = new JPanel();
        pnlRight.setBorder(new EmptyBorder(10, 10, 10, 10));
        pnlRight.setLayout(new GridLayout(2, 1));

        FriendsControl pnlFriends = new FriendsControl(maia,this);
        pnlFriends.setControlsDisabled();
        VillageInfo pnlVillageInfo = new VillageInfo(maia);

        pnlRight.add(pnlFriends);
        pnlRight.add(pnlVillageInfo);

        // Worldmap in the center 
        WorldMap pnlWorldMap = new WorldMap(this);
        //association
        //WorldMap --> VillageInfo : when you click on a village you need to get VillageInfo in other panel
        pnlWorldMap.setPnlVillageInfo(pnlVillageInfo);

        // Panel at the top 
        UpperBar pnlUpperBar = new UpperBar(this);

        // Sets the 3 containers in contentPane
        content.add(pnlUpperBar, BorderLayout.NORTH);
        content.add(pnlRight, BorderLayout.EAST);
        content.add(pnlWorldMap, BorderLayout.CENTER);
    }

    @Override
    public Maia getMaia() {
        return maia;
    }

    public void setMaia(Maia maia) {
        this.maia = maia;
    }

    public ChooseVillage getFrame() {

        return this;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 589, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 529, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
